package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.orderB.mapper.DriverSalaryMapper;
import com.egao.orderB.entity.DriverSalary;
import com.egao.orderB.service.DriverSalaryService;
import org.springframework.stereotype.Service;
import com.egao.orderB.biz.DriverSalaryBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 工资服务实现类
 * @author : Doman
 * @date : 2021-06-04 16:01:46
 * @version ：1.0
 */
@Service
public class DriverSalaryServiceImpl /*extends ServiceImpl<DriverSalaryMapper, DriverSalary> */implements DriverSalaryService {

	@Autowired
	private DriverSalaryBiz driverSalaryBiz;

    /**
    @Override
    public PageResult<DriverSalary> listPage(PageParam<DriverSalary> page) {
        List<DriverSalary> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<DriverSalary> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, DriverSalary driverSalary, User loginUser)  throws Exception{
        return driverSalaryBiz.list(page,driverSalary,loginUser);
    }

    @Override
    public JsonResult list(DriverSalary driverSalary, User loginUser) {
        return JsonResult.ok().setData(driverSalaryBiz.list(driverSalary,loginUser));
    }

    @Override
    public JsonResult getById(DriverSalary driverSalary) {
        return JsonResult.ok().setData(driverSalaryBiz.getById(driverSalary));
    }

    @Transactional
    @Override
    public JsonResult save(DriverSalary driverSalary, User loginUser) {
        if (driverSalaryBiz.save(driverSalary, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(DriverSalary driverSalary, User loginUser) {
        if (driverSalaryBiz.update(driverSalary, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(DriverSalary driverSalary, User loginUser) {
        if (driverSalaryBiz.remove(driverSalary, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
